import 'package:flutter/material.dart';
import 'package:moose_app/ui/values/values.dart';

import 'auth_text_field_wrap.dart';

class ATHAuthPasswordInput extends StatefulWidget {
  final String hintText;
  final IconData lockIcon;
  final ValueChanged<String> onChanged;
  final TextEditingController controller;

  const ATHAuthPasswordInput({
    Key key,
    this.hintText,
    this.lockIcon = Icons.lock,
    this.controller,
    this.onChanged,
  }) : super(key: key);

  @override
  _PasswordFiledState createState() => _PasswordFiledState();
}

class _PasswordFiledState extends State<ATHAuthPasswordInput> {
  bool obscureText = true;

  @override
  Widget build(BuildContext context) {
    return ATHAuthTextFieldWrap(
      child: TextField(
        obscureText: obscureText,
        onChanged: widget.onChanged,
        controller: widget.controller,
        decoration: InputDecoration(
          hintText: widget.hintText,
          icon: Container(
            padding: EdgeInsets.only(left: kSize16),
            child: Icon(
              widget.lockIcon,
              color: kColorPrimary,
            ),
          ),
          suffixIcon: GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: () {
              setState(() {
                obscureText = !obscureText;
              });
            },
            child: Icon(
              obscureText ? Icons.visibility_off : Icons.visibility,
              color: kColorPrimary,
            ),
          ),
          border: InputBorder.none,
        ),
      ),
    );
  }
}
